<html>
    <head>
        <meta charset="utf-8">
        <title>登录并绑定页</title>
    </head>
    <body>
        <div>你已通过 <b id="type">{{type}}</b> 授权，完善以下登录信息即可完成绑定</div>
        <div>
            <form method="post" action="/login">
                <input type="text" name="login_bind" value="true" hidden/><br/><!-- 隐藏字段，标识为登录并绑定 -->
                username:<input type="text" name="username"/><br/>
                password:<input type="password" name="password"/><br/>
                rememberMe:<input type="checkbox" name="remember-me"/>

                <br/><button id="loginBtn" type="submit" disabled>登录并绑定已有帐号</button>
                <a href="/">
                    <input type="button" value="返回"/>
                </a>
            </form>
        </div>
    </body>
</html>

<script type="text/javascript" src="./js/jquery-3.5.0.min.js"></script>
<script type="text/javascript">
window.onload = function(){
    $.ajax({
        url: "/curr-oauth",
        success: function(res){
            console.log(res)

            let ele = $("#type")
            let template = ele.html().trim()
            ele.html(template.replace("{{type}}", res.type || '--'))

            if(!!res.type){
                $("#loginBtn").removeAttr("disabled")
            }
        }
    })
}
</script>